//
//  HomeDetailViewController.m
//  ZAKER
//
//  Created by dllo on 15/8/31.
//  Copyright (c) 2015年 蓝鸥科技. All rights reserved.
//

#import "HomeDetailViewController.h"



@interface HomeDetailViewController ()<UITableViewDataSource, UITableViewDelegate>

@property (nonatomic, retain) UITableView *tableview;
@property (nonatomic, retain) UIImage *sendImage;
@property (nonatomic, retain) HomeModel *myModel;

@end

@implementation HomeDetailViewController

-(void)dealloc
{
    _tableview.delegate = nil;
    
    [_myModel release];
    [_sendImage release];
    [_tableview release];
    
    [super dealloc];
    
}


-(instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
    }
    return self;
    
}

- (void)viewDidLoad {
    
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    // 加小圈圈, 数据未加载出来时显示
    UIActivityIndicatorView *activity = [[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
    activity.frame = CGRectMake(self.view.frame.size.width - 15 * myWidth, self.view.frame.size.height - 15 * myHeight, 30 * myWidth, 30 * myHeight);
    activity.color = [UIColor lightGrayColor];
    [self.tableview addSubview:activity];
    [activity release];
    [self createTableView];    
}

-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    self.navigationController.navigationBar.hidden = NO;
}


#pragma mark - 点击图片放大,查看详情文字等
- (void)sendMyImage:(UIImage *)myImage myModel:(HomeModel *)myModel
{
    self.sendImage = myImage;
    self.myModel = myModel;
}

#pragma mark - 创建UITableView以及执行他的协议方法

-(void)createTableView
{
    
    self.tableview = [[[UITableView alloc]initWithFrame:[[UIScreen mainScreen] bounds] style:UITableViewStylePlain] autorelease];
    _tableview.delegate = self;
    _tableview.dataSource = self;
    [self.view addSubview:_tableview];

    
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 1;
}


-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    MyImageTableViewCell *cell = [_tableview dequeueReusableCellWithIdentifier:@"reuse"];
    if (cell == nil) {
        cell = [[[MyImageTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"reuse"] autorelease];
    }
    
    cell.image_urls.image = self.sendImage;
    cell.text.text = self.myModel.text;
    cell.string = self.myModel.text;
    
    return cell;
    
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    MyImageTableViewCell *cell = (MyImageTableViewCell *)[self tableView:tableView cellForRowAtIndexPath:indexPath];
    return cell.frame.size.height;
    
}
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
}

@end
